Nonlinear mixed-effect models for individual differences in growth (part 2)

Gompertz growth
R
STAN
brms
Bayesian
Author
Published

Friday, July 26, 2024

Load libraries

library(tidyverse); library(patchwork); library(tidybayes)
library(brms); library(marginaleffects); library(viridis)
library(easystats); library(kableExtra)

Set theme

theme_set(theme_bw(16))

We’re first going to load all model objects stored in the stan folder to avoid rerunning all those pesky Bayesian computations.

Code
# Make a vector of file paths
file_paths <- list.files(path = "stan/", 
                         pattern = "\\.rds", full.names = TRUE)

# Make a vector of file names
file_names <-  gsub(pattern = "\\.rds$", replacement = "", 
                    x = basename(file_paths))

# Read all models into a list
mods_list <- lapply(file_paths, readRDS)

# Assign file names to list elements
names(mods_list) <- file_names      

Rationale

Session info

sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.5

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Paris
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] kableExtra_1.4.0       see_0.8.5              report_0.5.9          
 [4] parameters_0.22.1      performance_0.12.2     modelbased_0.8.8      
 [7] insight_0.20.2         effectsize_0.8.9       datawizard_0.12.2     
[10] correlation_0.8.5      bayestestR_0.14.0      easystats_0.7.3       
[13] viridis_0.6.5          viridisLite_0.4.2      marginaleffects_0.21.0
[16] brms_2.21.6            Rcpp_1.0.13            tidybayes_3.0.6       
[19] patchwork_1.2.0        lubridate_1.9.3        forcats_1.0.0         
[22] stringr_1.5.1          dplyr_1.1.4            purrr_1.0.2           
[25] readr_2.1.5            tidyr_1.3.1            tibble_3.2.1          
[28] ggplot2_3.5.1          tidyverse_2.0.0       

loaded via a namespace (and not attached):
 [1] svUnit_1.0.6          tidyselect_1.2.1      loo_2.8.0.9000       
 [4] fastmap_1.2.0         tensorA_0.36.2.1      digest_0.6.36        
 [7] timechange_0.3.0      estimability_1.5.1    lifecycle_1.0.4      
[10] processx_3.8.4        magrittr_2.0.3        posterior_1.6.0      
[13] compiler_4.4.1        rlang_1.1.4           tools_4.4.1          
[16] utf8_1.2.4            yaml_2.3.9            data.table_1.15.4    
[19] knitr_1.48            bridgesampling_1.1-2  htmlwidgets_1.6.4    
[22] cmdstanr_0.8.1.9000   xml2_1.3.6            abind_1.4-5          
[25] withr_3.0.0           grid_4.4.1            fansi_1.0.6          
[28] xtable_1.8-4          colorspace_2.1-0      emmeans_1.10.3       
[31] scales_1.3.0          cli_3.6.3             mvtnorm_1.2-5        
[34] rmarkdown_2.27        generics_0.1.3        RcppParallel_5.1.8   
[37] rstudioapi_0.16.0     tzdb_0.4.0            bayesplot_1.11.1.9000
[40] parallel_4.4.1        matrixStats_1.3.0     vctrs_0.6.5          
[43] Matrix_1.7-0          jsonlite_1.8.8        hms_1.1.3            
[46] arrayhelpers_1.1-0    systemfonts_1.1.0     ggdist_3.3.2         
[49] glue_1.7.0            ps_1.7.7              distributional_0.4.0 
[52] stringi_1.8.4         gtable_0.3.5          munsell_0.5.1        
[55] pillar_1.9.0          htmltools_0.5.8.1     Brobdingnag_1.2-9    
[58] R6_2.5.1              evaluate_0.24.0       lattice_0.22-6       
[61] backports_1.5.0       rstantools_2.4.0.9000 svglite_2.1.3        
[64] coda_0.19-4.1         gridExtra_2.3         nlme_3.1-165         
[67] checkmate_2.3.1       xfun_0.46             pkgconfig_2.0.3